package com.by_man.presenter.module_health_management;

import android.content.Intent;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Button;

import com.by_man.presenter.R;
import com.by_man.presenter.SharedApplication;
import com.by_man.presenter.module_health_management.health_advice.HealthAdviceActivity;
import com.by_man.presenter.module_health_management.health_reminder.HealthReminderActivity;
import com.by_man.presenter.module_health_management.measure_blood_pressure.MeasureBloodPressureActivity;
import com.by_man.presenter.module_health_management.measure_blood_sugar.MeasureBloodSugarActivity;

/**
 * Created by man on 2017-01-31.
 */
public class HealthManagementFragment extends Fragment {

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState){
        View view = inflater.inflate(R.layout.fragment_health_management, container, false);

        // 对页面中的button注册监听器
        Button bloodPressureButton = (Button) view.findViewById(R.id.measure_blood_pressure_button);
        bloodPressureButton.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                Intent intent = new Intent(HealthManagementFragment.this.getActivity(), MeasureBloodPressureActivity.class);
                intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
                startActivity(intent);
            }
        });

        Button bloodSugarButton = (Button)view.findViewById(R.id.measure_blood_sugar_button);
        bloodSugarButton.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                Intent intent = new Intent(HealthManagementFragment.this.getActivity(), MeasureBloodSugarActivity.class);
                intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
                startActivity(intent);
            }
        });

        Button healthAdviceButton = (Button) view.findViewById(R.id.health_advice_button);
        healthAdviceButton.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                Intent intent = new Intent(HealthManagementFragment.this.getActivity(), HealthAdviceActivity.class);
                intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
                startActivity(intent);
            }
        });

        Button healthReminderButton = (Button) view.findViewById(R.id.health_reminder_button);
        healthReminderButton.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                Intent intent = new Intent(HealthManagementFragment.this.getActivity(), HealthReminderActivity.class);
                intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
                startActivity(intent);
            }
        });

        Button button5 = (Button) view.findViewById(R.id.button5);
        button5.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                SharedApplication.showToast(HealthManagementFragment.this.getActivity(), "功能开发中！");
            }
        });
        return view;
    }

}
